﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace worldParser
{
    abstract class CRobot : CSolid
    {
        string controller, controllerArgs;
        bool synchronisation, selfCollision; 
        CWorldArray battery;
        float cpuConsumption;

        public override void SetParamByName(Stack<IWorldStackObject> objstack, string param, List<string> values)
        {
            switch (param)
            {
                case "controller": controller = values[0]; break;
                case "controllerArgs": controllerArgs = values[0]; break;
                case "synchronisation": synchronisation = values[0][0] == 'T'; break;
                case "selfCollision": selfCollision = values[0][0] == 'T'; break;
                case "battery":  battery = new CWorldArray();
                                 objstack.Push(battery);
                                break;
                case "cpuConsumption": cpuConsumption = Float.Parse(values[0]); break;

                default: base.SetParamByName(objstack, param, values); break;
            }
        }
    }

    class CCustomRobot : CRobot
    {
    }

    class CSupervisor : CRobot
    {
    }

    class CDifferentialWheels : CRobot
    {    
        float motorConsumption, axleLength, wheelRadius, maxSpeed, maxAcceleration;
        float speedUnit, slipNoise, encoderNoise, encoderResolution, maxForce;

        public override void SetParamByName(Stack<IWorldStackObject> objstack, string param, List<string> values)
        {
            switch (param)
            {
                case "motorConsumption": motorConsumption = Float.Parse(values[0]); break;
                case "axleLength": axleLength = Float.Parse(values[0]); break;
                case "wheelRadius": wheelRadius = Float.Parse(values[0]); break;
                case "maxSpeed": maxSpeed = Float.Parse(values[0]); break;
                case "maxAcceleration": maxAcceleration = Float.Parse(values[0]); break;
                case "speedUnit": speedUnit = Float.Parse(values[0]); break;
                case "slipNoise": slipNoise = Float.Parse(values[0]); break;
                case "encoderNoise": encoderNoise = Float.Parse(values[0]); break;
                case "encoderResolution": encoderResolution = Float.Parse(values[0]); break;
                case "maxForce": maxForce = Float.Parse(values[0]); break;
                
                default: base.SetParamByName(objstack, param, values); break;
            }
        }
    }
}
